# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=qt5-webchannel
_basever=5.15.18
pkgver=5.15.18+kde+r3
pkgrel=3
_commit=2a157921861e651f43456cb7941b250c89feb736
arch=('x86_64' 'aarch64')
url='https://www.qt.io'
license=('GPL3' 'LGPL3' 'FDL' 'custom')
pkgdesc='Provides access to QObject or QML objects from HTML clients for seamless integration of Qt applications with HTML/JavaScript clients'
depends=('qt5-declarative')
makedepends=('git')
_pkgfqn=${pkgname/5-/}
source=("kde-$_pkgfqn::git+https://invent.kde.org/qt/qt/$_pkgfqn#commit=$_commit")
sha512sums=('ae150529cad63a53b62f8c266e7c1bc22311331edc70a48eb128493b720664278feed997ec63f756ea4223363223eb1d4d2c3bdec0c5fa2cb88b11a03583368f')

pkgver() {
  cd "kde-$_pkgfqn"

  echo "$_basever+kde+r"`git rev-list --count v$_basever-lts-lgpl..$_commit` |
    sed -e 's|+kde+r0||'
}

prepare() {
  mkdir -p build
}

build() {
  cd build

  qmake "../kde-$_pkgfqn"

  make
}

package() {
  cd build

  make INSTALL_ROOT="$pkgdir" install

  # Drop QMAKE_PRL_BUILD_DIR because reference the build dir
  find "$pkgdir/usr/lib" -type f -name '*.prl' \
    -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

  install -d "$pkgdir/usr/share/licenses"
  ln -s /usr/share/licenses/qt5-base "$pkgdir/usr/share/licenses/$pkgname"
}

